﻿using Abp.AspNetCore.Mvc.Controllers;
using Abp.Runtime.Caching;
using Batman.Cms.Core.Models.Mvc;
using Batman.Jianbei.Forum.Core.Consts;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Batman.Jianbei.Forum.Areas.Admin
{
    [Area(RouteNames.Admin)]
    public class CacheController : AbpController
    {
        public ICacheManager CacheManager { get; set; }

        /// <summary>
        /// 清除索引的缓存
        /// </summary>
        /// <returns></returns>
        public bool Clean()
        {
            CacheManager.GetAllCaches().ToList().ForEach(t => t.Clear());
            return true;
        }

        /// <summary>
        /// 获取全部缓存
        /// </summary>
        /// <returns></returns>
        public List<string> Get()
        {
            return CacheManager.GetAllCaches().Select(t => t.Name).ToList();
        }
    }
}
